<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>图书管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#batchNumber").focus();
            $("#purchaseForm").validate({
                submitHandler: function(form){

                    var batchNumber = $("#batchNumber").val();
                    if (batchNumber != "") {
                        $.post("${ctx}/book/purchase/checkRepeatBatchNumber", {batchNumber: batchNumber}, function (result) {
                            if (result.code == '0001') {
                                loading('正在提交，请稍等...');
                                form.submit();
                            } else {
                                alertx(result.msg);
                            }
                        });
                    }
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/book/purchase/list">采购批次</a></li>
    <li class="active"><a href="">新增批次</a></li>
</ul>
<br/>
<form:form id="purchaseForm" modelAttribute="bkPurchaseBatch" action="${ctx}/book/purchase/addPurchase" method="post"
           class="form-horizontal">
    <div class="control-group">
        <label class="control-label">批次编号:</label>

        <div class="controls">
            <form:input path="batchNumber" htmlEscape="false" maxlength="20"  class="required" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">发票编号:</label>

        <div class="controls">
            <form:input path="invoice" htmlEscape="false" maxlength="50" />
        </div>
    </div>

    <div class="control-group">
        <label class="control-label">备注：</label>

        <div class="controls">
            <form:textarea path="remarks" htmlEscape="false" maxlength="30" class="input-medium"/>
        </div>
    </div>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>
</form:form>
</body>
</html>